#!/bin/bash
jar=$1
class=$2
shift 2
#NOTE: There seems to be a bug in hadoop 0.20.1 where -Dfs.default.name=hdfs://host:port
# variable override does not work, so instead, I write to a config file
conffile=/tmp/hdenv-$hdname-$RANDOM.conf
echo Creating temporary config $conffile
cat > $conffile <<DELIM
<?xml version="1.0"?>
<configuration>
	<property>
		<name>fs.default.name</name>
		<value>$hdnamenode</value>
	</property>
	<property>
		<name>mapred.job.tracker</name>
		<value>$hdtracker</value>
	</property>
	<property>
		<name>hadoop.job.ugi</name>
		<value>$hduser, $hdgroup</value>
	</property>
</configuration>
DELIM
cat $conffile
echo hadoop jar ${jar} ${class} -conf $conffile $@
hadoop jar ${jar} ${class} -conf $conffile $@
ret=$$
rm $conffile
exit $ret
